package leetcode1;

public class Day10 {
    public String optimalDivision(int[] nums) {
        int n = nums.length;
        StringBuilder ret = new StringBuilder();
        if(n==1) {
            String ch =  String.valueOf(nums[0]);
            ret.append(ch);
            return ret.toString();
        }
        if(n==2) {
            String ch1 = String.valueOf(nums[0]);
            String ch2 = String.valueOf(nums[1]);
            ret.append(ch1);

            ret.append("/");
            ret.append(ch2);
            return ret.toString();
        }
        for(int i=0;i<n;i++) {
            String ch = String.valueOf(nums[i]);
            if(i != n-1) {
                ret.append(ch);
                ret.append("/");
            }else ret.append(ch);
            if(i == 0) ret.append("(");
            if(i == n-1) ret.append(")");
        }
        return ret.toString();
    }
}
